import http from "../utils/http"
import { PDA_API, FEED_API } from "../config"
//用于获取验证
//1.设备投料
export const device = (productionLine, code, item) => {
  return http.post(`${FEED_API}/GetSKUItems`, {
    Line: productionLine,
    Encode: code,
    ItemName: item,
  }).then(res => res.data)
}

export const standardQuantity = (productionLine, code) => {
  return http.post(`${PDA_API}/StandardQuery`, {
    Production: productionLine,
    Materiel: code
  }).then(res => res.data)
}

export const formulaRatio = (productionLine, code) => {
  return http.post(`${PDA_API}/FormulaMaterielQuery`, {
    Production: productionLine,
    Materiel: code
  }).then(res => res.data)
}

export const bom = (type, user, line, id, material, bill) => {
  return http.post(`${PDA_API}/BomQuery`, {
    Type: type,
    UserAccount: user,
    Line: line,
    UniqueId: id,
    ProductId: material,
    BillType: bill,
  }).then(res => res.data)
}
//工单日期选择
export const workOrder = (startAt, endAt, line) => {
  return http.post(`${FEED_API}/GetProcessOrderList`, {
    StartDate: startAt,
    EndDate: endAt,
    Line: line
  }).then(res => res.data)
}

//用于提交
//WIP，设备，标准量，配方比
export const commissionSubmit = (line, id, material, bill, user, type, devicecode, houseid, orderno, SeqNo, num, batchno, packerid, potcode) => {
  return http.post(`${FEED_API}/FeedingOperate`, {
    Line: line,
    UniqueId: id,
    ProductId: material,
    BillType: bill,
    UserAccount: user,
    Type: type,
    DeviceCode: devicecode,
    WareHouseId: houseid,
    ProcessOrderNO: orderno,
    SeqNo: SeqNo,
    Num: num,
    BatchNo: batchno,
    Rer04: packerid,
    Rer09: potcode
  }).then(res => res.data)
}
//BOM
export const ConfirmSubmit = (line, id, material, bill, user, type) => {
  return http.post(`${FEED_API}/OutStorageOperate`, {
    Line: line,
    UniqueId: id,
    ProductId: material,
    BillType: bill,
    UserAccount: user,
    Type: type,
  }).then(res => res.data)
}
//查询已投料的数据
export const getFedData = (line, id, houseid, seqno) => {
  return http.post(`${FEED_API}/GetFedList`, {
    Line: line,
    UniqueId: id,
    WareHouseId: houseid,
    SeqNo: seqno
  }).then(res => res.data)
}

//退回
export const EndPost = (list) => {
  return http.post(`${FEED_API}/CancelOutStorage`, {
    Items: list,
  }).then(res => res.data)
}

//设备获取
export const DeviceGive = (code, line) => {
  return http.post(`${FEED_API}/GetSKUList`, {
    Encode: code,
    Line: line
  })
}

//设备相关的物料获取,获取配方比相关数据
export const DeviceMaterial = (productionLine, code, item) => {
  return http.post(`${FEED_API}/GetSKUItems`, {
    Line: productionLine,
    Encode: code,
    ItemName: item
  }).then(res => res.data)
}

//全部提交 Bom
export const allPush = (line, bill, user, type, list, houseid) => {
  return http.post(`${FEED_API}/OutStorageOperate`, {
    Line: line,
    BillType: bill,
    UserAccount: user,
    Type: type,
    Items: list,
    WareHouseId: houseid
  }).then(res => res.data)
}

//获取配方比的配方
export const GetPFItem = (user, line, code, bacth, type) => {
  return http.post(`${FEED_API}/GetBOMItems`, {
    Line: line,
    UserAccount: user,
    DeviceCode: code,
    BatchNo: bacth,
    BillType: type
  }).then(res => res.data)
}

//结束批次
export const OverOutStorage = (user, line, code, batch, type) => {
  return http.post(`${FEED_API}/OverOutStorage`, {
    Line: line,
    UserAccount: user,
    DeviceCode: code,
    BatchNo: batch,
    BillType: type
  }).then(res => res.data)
}

//获取当前批次的详细信息
export const GetPFIList = (user, line, code, bacth, type) => {
  return http.post(`${FEED_API}/GetBomFeedingList`, {
    Line: line,
    UserAccount: user,
    DeviceCode: code,
    BatchNo: bacth,
    BillType: type
  }).then(res => res.data)
}
//查询
export const SerachList = (productionline, palletNo, id) => {
  return http.post(`${FEED_API}/GetStockRealDetail2`, {
    UniqueId: palletNo,
    Line: productionline,
    WareHouseId: id,
  }
  ).then(res => res.data)
}
//查询卷心号
export const GetWindNumber = (productionline, palletNo, user, material, procoder) => {
  return http.post(`${FEED_API}/GetWindingNumberSettingList`, {
    UniqueId: palletNo,
    Line: productionline,
    UserAccount: user,
    ProductId: material,
    PROCORDER: procoder
  }
  ).then(res => res.data)
}
//提交膜卷领料
export const SaveWindNumber = (productionline, palletNo, user, item, material) => {
  return http.post(`${FEED_API}/SaveWindingNumberSetting`, {
    UniqueId: palletNo,
    Line: productionline,
    UserAccount: user,
    Items: item,
    ProductId: material
  }
  ).then(res => res.data)
}

//检查桶能否投料
export const checkbucketDeatil = (line, material, bucketno) => {
  return http.post(`${FEED_API}/CheckReworkOutStorage`, {
    Line: line,
    ProductId: material,
    BucketCode: bucketno
  }).then(res => res.data)
}

//返工投料
export const workAgainSubmit = (user, line, material, bucketno, weight, productnumber, ischange, ordermaterial) => {
  return http.post(`${FEED_API}/ReworkOutStorage`, {
    UserAccount: user,
    Line: line,
    ProductId: material,
    BucketCode: bucketno,
    WeightUsed: weight,
    ProductOrder: productnumber,
    IsChange: ischange,
    Material: ordermaterial
  }).then(res => res.data)
}

//获取包装机
export const GetWindingPackerList = (line) => {
  return http.post(`${FEED_API}/GetWindingPackerList`, {
    Line: line,
  }).then(res => res.data)
}

//获取锅码
export const GetPotCodeList = (line) => {
  return http.post(`${FEED_API}/GetPotCodeList`, {
    Line: line,
  }).then(res => res.data)
}

//获取最终投产状态
export const GetOutStorege = (line) => {
  return http.post(`${FEED_API}/GetOutStorege`, {
    Line: line,
  }).then(res => res.data)
}

//获取返工号
export const GetReworkMaterials = (materials) => {
  return http.post(`${FEED_API}/GetReworkMaterials`, {
    Material: materials,
  }).then(res => res.data)
}